<template>
    <div>
        <div class="container">
            <!-- 头部 -->
            <div class="nav">
                <div class="nav_wrap">
                    <div class="quit" @click="$router.back()"></div>
                    <div class="subnav">
                        <!-- <ul>
                            <li class="con">男频</li>
                            <li>女频</li>
                            <li>悬疑</li>
                        </ul> -->
                        排行
                    </div>
                    <div class="nav_icon">
                        <router-link tag="a" to="/shelf"></router-link>
                        <i v-show="!isTop" @click="topShow"></i>
                        <i class="topnav" v-show="isTop" @click="topShow"></i>
                    </div>
                </div>
            </div>
            <div class="wrap" v-show="isTop" @click.self="topShow">
                <div class="subnav">
                    <ul>
                        <router-link tag="li" to="/">
                            <img src="../assets/images/tp_1.png" alt="">
                            <span>首页</span>
                        </router-link>
                        <router-link tag="li" to="/library">
                            <img src="../assets/images/tp_02.png" alt="">
                            <span>书库</span>
                        </router-link>
                        <router-link tag="li" to="/shelf">
                            <img src="../assets/images/tp_03.png" alt="">
                            <span>书架</span>
                        </router-link>
                        <router-link tag="li" to="/user">
                            <img src="../assets/images/tp_04.png" alt="">
                            <span>账户</span>
                        </router-link>
                        <router-link tag="li" to="/pay">
                            <img src="../assets/images/tp_05.png" alt="">
                            <span>充值</span>
                        </router-link>
                        <router-link tag="li" to="/search">
                            <img src="../assets/images/tp_06.png" alt="">
                            <span>搜索</span>
                        </router-link>
                    </ul>
                </div>
            
            </div>

            <!-- 选项卡 -->
            <div class="tabs bor_bot">
                <ul>
                    <li :class="[con == 0 ? 'con':'']" @click="con = 0"><span>订阅</span></li>
                    <li :class="[con == 1 ? 'con':'']" @click="con = 1"><span>完本</span></li>
                    <li :class="[con == 2 ? 'con':'']" @click="con = 2"><span>新书</span></li>
                    <li :class="[con == 3 ? 'con':'']" @click="con = 3"><span>点击</span></li>
                </ul>
                <div class="list_books">
                    <div class="books_cont" v-if="booksData">
                        <ul>
                            <router-link tag="li" :to="{ path: '/about', query: { userId: item.id } }" v-for="(item,index) in booksData"
                                :key="index">
                                <div class="img">
                                    <!-- <img src="../assets/images/vip.jpg" alt="" :data-src="item.iconUrl"> -->
                                    <img :src="item.iconUrl">
                                </div>
                                <div class="intro">
                                    <div class="in_tit">
                                        {{item.title}}
                                    </div>
                                    <p>
                                        {{ item.description }}
                                    </p>
                                    <div class="in_foot">
                                        <div class="state">
                                            <span>{{ item.bookStatus ? '完结' : '连载'}}</span>
                                        </div>
                                        <div class="book_type">
                                            <span class="book_num">{{ item.showTotalCount }}</span>
                                            <span>{{ item.category }}</span>
                                        </div>
                                    </div>
                                </div>
                            </router-link>
                        </ul>
                    </div>
                </div>
                <van-loading color="#e7423d" size="30px"/>
                <h3>加载中…</h3>
            </div>
            <!-- 搜索框 -->
            <router-link tag="div" to="/search" class="search">
                <div class="search_wrap">
                    <input type="text">
                    <button></button>
                </div>
            </router-link>
            <!-- 页脚信息 -->
            <div class="footer">
                <div class="foot_tit">
                    <ul>
                        <li>
                            <a href="javascript:;">首页</a>
                        </li>
                        <li>
                            <a href="javascript:;">书库</a>
                        </li>
                        <li>
                            <a href="javascript:;">书架</a>
                        </li>
                        <li>
                            <a href="javascript:;">账户</a>
                        </li>
                        <li>
                            <a href="javascript:;">客户端</a>
                        </li>
                    </ul>
                </div>
                <div class="foot_cont">
                    <div class="foot_info">
                        <p>客服QQ群：326738643</p>
                        <p>客服电话：010-86462015-800</p>
                        <p>©2020北京爱书客科技有限公司</p>
                        <p>京ICP备13037522号</p>
                    </div>
                    <div class="info_img">
                        <img src="../assets/images/ledu.png" alt="">
                        <span>乐读书城</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import { getJsonData } from '../api/home';
    export default {
        data(){
            return{
                booksData:null,//书单数据
                isTop: false,//判断子菜单的展示
                con:0//下标控制
            }
        },
        created() {
            this.getdata()//刷星数据
        },
        methods:{
            topShow() {
                this.isTop = !this.isTop
            },
            getdata(){//获取书籍信息
                getJsonData().then(data => {
                    this.booksData = data.data.books;
                    
                })
            }
        }
    }
</script>

<style lang="scss" scoped>
.nav {
    padding: 0 14px;
    border-bottom: 1px solid #e0e0e0;

    .nav_wrap {
        display: flex;
        align-items: center;
        justify-content: space-between;
        .quit {
            width: 10px;
            height: 45px;
            background-image: url('../assets/images/quit.png');
            background-repeat: no-repeat;
            background-size: 100%;
            background-position: center;
        }
        .subnav {
            padding-left: 66px;
            &>ul {
                display: flex;
                width: 138px;
                height: 26px;
                margin: auto;
                border-radius: 13px;
                background-color: #f0f0f0;
                overflow: hidden;

                &>li {
                flex: 1;
                text-align: center;
                color: #000;
                height: 26px;
                line-height: 26px;
                }

                &>.con {
                background-color: #ea4136;
                color: #fff;
                border-radius: 13px;
                }
            }
        }
        span {
            color: #333;
            font-size: 16px;
            display: block;
            text-align: center;
            line-height: 45px;
            width: 54%;
            padding-left: 70px;
        }

        .nav_icon {
            display: flex;
            align-items: center;
            justify-content: space-between;
            width: 80px;

            a {
                display: block;
                width: 25px;
                height: 22px;
                background-image: url('../assets/images/book_ico1.png');
                background-repeat: no-repeat;
                background-size: 100%;
                background-position: center;
            }

            i {
                display: block;
                width: 20px;
                height: 20px;
                background-image: url('../assets/images/bookMore_ico1.png');
                background-size: 100%;
                background-position: center;

            }
            .topnav {
                background-image: url('../assets/images/tp_close.png');
            }
        }
    }
}
.wrap {
    position: fixed;
    top: 45px;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(0, 0, 0, .8);

    .subnav {
        width: 100%;
        background-color: #fff;
        padding-bottom: 18px;

        ul {
            display: flex;
            flex-wrap: wrap;

            li {
                width: 25%;
                text-align: center;
                padding-top: 20px;

                img {
                    width: 40px;
                    height: 40px;
                    margin: 0 auto 8px auto;
                }

                span {
                    font-size: 13px;
                    color: #666;
                }
            }
        }
    }

}


.tabs{
    padding-bottom: 20px;
    &>ul{
        display: flex;
        justify-content: space-between;
        li{
            flex: 1;
            span{
                display: block;
                width: 55px;
                height: 42px;
                line-height: 42px;
                text-align: center;
                font-size: 16px;
                color: #666;
                padding: 1px 1px;
                border-bottom: 3px solid transparent;
                margin: 0 auto;
            }
        }
        .con{
            span{
                color: #e7423d;
                border-color: #e7423d;
            }
        }
    }
    .list_books {
        padding: 0 14px;

        .books_cont {
            .sort_uls {
                padding-bottom: 0px;
            }

            ul {
                padding-bottom: 28px;

                li {
                    display: flex;
                    padding-top: 24px;

                    .img {
                        flex: 1;

                        img {
                            width: 100px;
                            height: 140px;
                        }
                    }

                    .intro {
                        flex: 2;
                        padding-left: 5px;

                        .in_tit {
                            height: 47px;
                            color: #666;
                            font-size: 18px;
                        }

                        &>p {
                            height: 47px;
                            line-height: 22px;
                            font-size: 13px;
                            color: #999;
                            text-indent: 26px;
                            overflow: hidden;
                        }
                    }

                    .in_foot {
                        display: flex;
                        justify-content: space-between;
                        padding-top: 29px;

                        span {
                            border: 1px solid #fff;
                            display: block;
                            font-size: 12px;
                            height: 10px;
                            line-height: 10px;
                            padding: 2px 3.5px;
                        }

                        .state {
                            span {
                                border-color: #ea4136;
                                color: #ea4136;
                            }
                        }

                        .book_type {
                            display: flex;

                            .book_num {
                                border-color: #f39800;
                                color: #f39800;
                                margin-right: 6px;
                            }

                            span {
                                border-color: #706262;
                                color: #706262;
                            }
                        }
                    }
                }
            }
        }

    }
    .van-loading{
        display: flex;
        justify-content: center;
    }
    h3{
        text-align: center;
        font-size: 15px;
        color: #333;
        font-weight: normal;
        padding-top: 8px;
    }
}
.bor_bot {
    border-bottom: 10px solid #eaeaea;
}
.search {
    padding: 10px 14px;

    .search_wrap {
        display: flex;
        padding: 4px 0 4px 17px;
        border: 1px solid #dbdbdb;
        height: 32px;
        border-radius: 20px;
        overflow: hidden;

        &>input {
            border: 0px;
            outline: none;
            flex: 6;
            color: #999;
        }

        &>button {
            flex: 1;
            background-image: url('../assets/images/searchBar.png');
            background-repeat: no-repeat;
            border: 0px;
            background-color: #fff;
            position: relative;
            border-left: 1px solid #dbdbdb;
            background-size: 18px;
            background-position: center;
        }
    }
}

.footer {
    padding: 16px 0px 32px 0px;
    background-color: #1c1a1a;

    .foot_tit {
        padding-bottom: 15px;

        ul {
            display: flex;

            li {
                flex: 1;

                a {
                    display: block;
                    font-size: 16px;
                    color: #b6b6b6;
                    text-align: center;
                    border-right: 1px solid #999999;

                }

                &:last-of-type {
                    a {
                        border: 0px;
                    }
                }
            }
        }
    }

    .foot_cont {
        display: flex;
        justify-content: space-between;
        padding: 0 16px;

        .foot_info {
            p {
                color: #b6b6b6;
                font-size: 12px;
                line-height: 28px;
            }
        }

        .info_img {
            img {
                width: 98px;
                height: 98px;
            }

            span {
                font-size: 12px;
                display: block;
                text-align: center;
                color: #b6b6b6;
                padding-top: 3px;
            }
        }
    }
}
</style>